package demo.spring.ex01.hello;

import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.GenericApplicationContext;

/**
 * 
 * 代码摘抄自： <http://projects.spring.io/spring-framework/>
 * 
 * @author pactera
 *
 */

@Configuration
@ComponentScan
public class Application {
	
	@Bean
	MessageService mockMessageService() {
		return new MessageService() {
			public String getMessage() {
				return "Hello World!";
			}
		};
	}

	@SuppressWarnings({ "restriction", "unused" })
	public static void main(String[] args) {
		@SuppressWarnings("resource")
		ApplicationContext context = new AnnotationConfigApplicationContext(Application.class);
		MessagePrinter printer = context.getBean(MessagePrinter.class);
		printer.printMessage();
		
		/**
		 * http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#spring-core
		 * GenericApplicationContext context = new GenericApplicationContext();
		 * new XmlBeanDefinitionReader(context).loadBeanDefinitions("services.xml", "daos.xml");
		 * context.refresh();
		 */
		GenericApplicationContext context0 = null;
		XmlBeanDefinitionReader reader = null;
		
		com.sun.org.apache.xerces.internal.impl.Constants.main(new String[]{});
		
	}
}
